package cn.itcast.mapper;

import cn.itcast.pojo.QueryString;
import cn.itcast.pojo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentMapper {
    //分页查询学生信息
    List<Student> findByPage(QueryString queryString);

    //添加学生
    @Insert("insert into student (name, no, gender, phone, id_card, is_college, address, degree,graduation_date,clazz_id) values (#{name},#{no},#{gender},#{phone},#{id_card},#{is_college},#{address},#{degree},#{graduation_date},#{clazz_id})")
    int add();

    //批量删除学员
    int deleteByIds(@Param("ids") int[] ids);

    @Select("select * from student where id = #{id}")
    Student findById(Integer id);

    @Update("update student set name=#{name}, no=#{no}, gender=#{gender}, phone=#{phone}, id_card=#{idCard}, is_college=#{isCollege}, address=#{address}, degree=#{degree}, graduation_date=#{graduationDate}, clazz_id=#{clazzId} where id=#{id}")
    int update(Student student);

    // 在StudentMapper接口中修改方法签名
    @Update("update student set violation_count = (violation_count + 1),violation_score = #{score} where id = #{id}")
    int updates(@Param("id") Integer id, @Param("score") Integer score);

}
